package com.wangjn;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by Administrator on 2017/5/9.
 */
public class Start {
        private static Logger logger = LoggerFactory.getLogger(Start.class);
        private static Start instance;

        /**
         * 获取默认单例
         *
         * @return 单例
         */
    public static Start getInstance() {
        if (instance == null) {
            synchronized (Start.class) {
                if (instance == null)
                    instance = new Start();
            }
        }
        return instance;
    }

    public  void startup() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[] { "applicationContext.xml" });
        context.start();
    }

    public static void main(String[] args) {
        getInstance().startup();
        logger.info("service run success!!!");
        while (true) {
        }//执行完后程序自动与注册中心断开联系，加个死循环不让与中心断开
    }
}
